package lc20240423;

class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;

    TreeNode() {
    }

    TreeNode(int val) {
        this.val = val;
    }

    TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
}

class Solution{
    //求二叉树最大深度。
    public static int maxDepth(TreeNode root){
        if (root==null){
            return 0;
        }else {
            int a=maxDepth(root.left);
            int b=maxDepth(root.right);
            return a>b?a+1:b+1;
        }
    }
}
public class MaxHeight {
    public static void main(String[] args) {

    }
}
